

package com.hexinfo.dmpro.dev.data.transfer.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hexinfo.dmpro.dev.data.transfer.model.DesensitizeFieldMap;
import com.hexinfo.dmpro.dev.data.transfer.service.IDesensitizeFieldMapService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;


/**
 * 脱敏字段映射表
 *
 * @author zh.wang
 * @date 2023-09-19 19:04:23
 */
@RestController
@AllArgsConstructor
@RequestMapping("/api/desensitizeFieldMap")
@Api(value = "desensitizeFieldMap", tags = "脱敏字段映射表管理")
public class DesensitizeFieldMapController {

    private final IDesensitizeFieldMapService desensitizeFieldMapService;

    /**
     * 分页查询
     *
     * @param page                 分页对象
     * @param desensitizeFieldMap 脱敏字段映射表
     *                             WrapperEnhancer.like(DesensitizeFieldMap); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    public ResponseEntity<Object> getDesensitizeFieldMapPage(Page page, DesensitizeFieldMap desensitizeFieldMap) {
        return ResponseEntity.ok(desensitizeFieldMapService.queryList(page, desensitizeFieldMap));
    }

    /**
     * 修改脱敏字段映射表
     *
     * @param DesensitizeFieldMap 脱敏字段映射表
     * @return R
     */
    @ApiOperation(value = "修改脱敏字段映射表", notes = "修改脱敏字段映射表")
    @PutMapping
    public ResponseEntity<Object> updateById(@RequestBody DesensitizeFieldMap DesensitizeFieldMap) {
        return ResponseEntity.ok(desensitizeFieldMapService.updateById(DesensitizeFieldMap));
    }

    /**
     * 通过id删除脱敏字段映射表
     *
     * @param ids id
     * @return R
     */
    @ApiOperation(value = "通过id删除脱敏字段映射表", notes = "通过id删除脱敏字段映射表")
    @DeleteMapping("/{ids}")
    public ResponseEntity<Object> removeByIds(@PathVariable("ids") @NotNull List<String> ids) {
        return ResponseEntity.ok(desensitizeFieldMapService.removeByIds(ids));
    }

}
